from fastapi import APIRouter
from typing import Dict, Any

router = APIRouter()

@router.get("/stats")
async def get_dashboard_stats() -> Dict[str, Any]:
    """获取仪表盘统计数据"""
    return {
        "onlineSensors": 156,
        "todayData": 12480,
        "alerts": 3,
        "avgPH": 6.8,
        "avgSOC": 2.35,
        "totalPlots": 45
    }

@router.get("/recent-data")
async def get_recent_data(limit: int = 10):
    """获取最近的土壤数据"""
    return {
        "data": [
            {
                "timestamp": "2024-11-11 18:30:00",
                "plot_id": "P001",
                "ph": 6.7,
                "soc": 2.41,
                "moisture": 23.5,
                "temperature": 18.2
            },
            {
                "timestamp": "2024-11-11 18:25:00",
                "plot_id": "P002",
                "ph": 7.1,
                "soc": 2.28,
                "moisture": 25.1,
                "temperature": 17.8
            }
        ]
    }
